package com.qiusuo0226;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;

/**
 * 启动类
 * - @EnableAspectJAutoProxy 开启组件扫描和AOP自动代理
 */
@EnableAspectJAutoProxy
@SpringBootApplication
@Slf4j
public class ProjectnameModulenameServerApplication extends SpringBootServletInitializer {

	public static void main(String[] args) {
		ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(ProjectnameModulenameServerApplication.class, args);
		Environment environment = configurableApplicationContext.getBean(Environment.class);
		// 项目的根环境
		String path = "http://localhost:" + environment.getProperty("server.port") + environment.getProperty("server.servlet.context-path");
		String xxlJobPath = environment.getProperty("xxl.job.admin.address");
		String activeProfile = environment.getProperty("spring.profiles.active");
		log.info(" ============> {}环境 启动成功！", activeProfile);
		log.info(" ============> 项目地址：{}", path);
		log.info(" ============> Xxl-Job调度器控制台地址：{}", xxlJobPath);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		// 注意这里要指向原先用main方法执行的Application启动类
		return builder.sources(ProjectnameModulenameServerApplication.class);
	}


}
